package bitmap

import "fmt"

type Bitmap_a struct {
	max_len   int
	bit_array []byte
}

func New_bitmap(count int) *Bitmap_a {
	max := (count + 7) / 8
	bm := &Bitmap_a{}
	bm.max_len = max
	bm.bit_array = make([]byte, max, max)
	return bm
}

func (bm *Bitmap_a) Set(id int) {
	if id > bm.max_len {
		return
	}
	array_index := id / 8
	bit_index := 1 << (id % 8)
	bm.bit_array[array_index] |= byte(bit_index)
}

func (bm *Bitmap_a) Get(id int) bool {
	if id > bm.max_len {
		return false
	}
	array_index := id / 8
	bit_index := 1 << (id % 8)
	return bm.bit_array[array_index]&byte(bit_index) != 0
}

func Add() {
	fmt.Println("Add")
}
